﻿import Enum from './mutation-enum.js'
import { stat } from 'fs';
/** 
 * mutations
 * 提交状态修改。也就是set、get中的set，这是vuex中唯一修改state的方式，但不支持异步操作。
 * 第一个参数默认是state。外部调用方式：store.commit('SET_AGE', 18)。和vue中的methods类似。
 */
export default {
    /**
     * 存储已选择检测项目类型、检测项目、总计
     * 单一选择
     * @param {*} { commit }
     * @param {*} args
     */
    [Enum.SET_TEST_ITEM]: (state, args) => {
        state.testItemTypeList = [];
        state.packageList = [];
        state.testItemList = [];
        state.total = 0;

        state.testItemTypeList.push(...args.selectTestItemTypeList);
        state.packageList.push(...args.selectTestItemPackageList);
        state.testItemList.push(...args.selectTestItemList);
        state.total = args.total;

        console.log('one:', state.testItemTypeList);
        console.log('three:', state.packageList);
        console.log('two:', state.testItemList);
        console.log('total:', state.total);
    },
    /**
     * 存储订单信息
     * @param {*} { commit }
     * @param {*} params
     */
    [Enum.SET_ORDER_INFO]: (state, params) => {
        state.orderInfo = {};
        state.orderInfo = params;
    },
    /**
     * 存储已选检测项目编号
     * @param {*} { commit }
     * @param {*} ids
     */
    [Enum.SET_ITEM_IDS]: (state, ids) => {
        state.orderInfo.ItemIds = [];
        state.orderInfo.ItemIds.push(...ids);
    },
    /**
     * 重置
     * @param {*} { commit }
     */
    [Enum.RESET]: (state) => {
        state.testItemTypeList = [];
        state.testItemList = [];
        state.packageList = [];
        state.total = 0;
    }
}